#
cmake_minimum_required(VERSION 3.5)
#
project(speex_test)

# 指定编译器
# set(CMAKE_C_COMPILER   "${CROSS_TOOLCHAIN_PREFIX}gcc")
# set(CMAKE_CXX_COMPILER "${CROSS_TOOLCHAIN_PREFIX}g++")

set(CMAKE_BUILD_TYPE "Debug")
# set(CMAKE_BUILD_TYPE "Release")
# set(CMAKE_BUILD_TYPE "RelWithDebInfo")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")       # C语言优化等级
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")   # C++优化等级

message(STATUS "cmake build type = ${CMAKE_BUILD_TYPE}")

# 指定C ++标准
# set(CMAKE_CXX_STANDARD 11)
# set(CMAKE_CXX_STANDARD_REQUIRED True)

add_definitions(-DFLOATING_POINT)
add_definitions(-DUSE_SMALLFT) # USE_SMALLFT USE_KISS_FFT
# add_definitions(-DFIXED_POINT)

include_directories(     
    #${PROJECT_SOURCE_DIR}
    ${PROJECT_SOURCE_DIR}/include
    ${PROJECT_SOURCE_DIR}/libspeexdsp
)

set(SPEEX_SRC 
    # libspeexdsp/buffer.c
    libspeexdsp/fftwrap.c
    libspeexdsp/filterbank.c
    # libspeexdsp/jitter.c
    libspeexdsp/kiss_fft.c
    libspeexdsp/kiss_fftr.c
    libspeexdsp/smallft.c
    libspeexdsp/mdf.c
    libspeexdsp/preprocess.c   
    # libspeexdsp/denoise.c  
    # libspeexdsp/resample.c
    # libspeexdsp/scal.c    
)

# # 生成可执行文件
# add_executable(speex_test ${PROJECT_SOURCE_DIR}/echo_test.c ${SPEEX_SRC})
# target_compile_options(speex_test PRIVATE "-w")
# target_link_libraries(speex_test PRIVATE m)

# add_executable(vad_test ${PROJECT_SOURCE_DIR}/vad_test.c ${SPEEX_SRC} ${PROJECT_SOURCE_DIR}/echosuppression/vadfft.c)
# target_compile_options(vad_test PRIVATE "-w")
# target_link_libraries(vad_test PRIVATE m)

# pipeline测试
# 清除cmake中间的cache文件
# add_executable(cmakeclean ${PROJECT_SOURCE_DIR}/cmake_clean.c)

# add_executable(speexmain ${PROJECT_SOURCE_DIR}/gcc_phat_test.c ${SPEEX_SRC})
# target_link_libraries(speexmain PRIVATE m)

add_executable(speexmain 
    ${PROJECT_SOURCE_DIR}/beamformer_test.c 
    ${SPEEX_SRC} 
    ${PROJECT_SOURCE_DIR}/beamformer.c
)
target_link_libraries(speexmain PRIVATE m)